﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WmWebSystem.Models
{
    public class INetMvc3Page
    {
        /// <summary>
        /// 当前页
        /// </summary>
        public int CurrentPageIndex { get; set; }

        int _DispPageCount = 10;
        /// <summary>
        /// 条目显示的页数
        /// </summary>
        public int DispPageCount
        {
            get 
            {
                return _DispPageCount;
            }
            set
            {
                _DispPageCount = value;
            }
        }

        int _PageSize = 20;
        /// <summary>
        /// 每页记录数 默认20条记录一页
        /// </summary>
        public int PageSize
        {
            get 
            {
                return _PageSize;
            }
            set 
            {
                _PageSize = value;
            }
        }
        public int TotalCount { get; set; }
        /// <summary>
        /// 获取总页数
        /// </summary>
        public int TotalPage
        {
            get
            {
                int PageCount = 0;
                if (PageSize > 0 && TotalCount > 0)
                {
                    PageCount = TotalCount / PageSize;
                    int Count = TotalCount % PageSize;
                    if (Count > 0)
                    {
                        PageCount = PageCount + 1;
                    }
                }
                return PageCount;
            }
        }
        public int PageFirst
        {
            get
            {
                int result = 1;
                //当前页大于要显示的页。起始页肯定不是第一页
                if (CurrentPageIndex > _DispPageCount)
                {
                    int num = (CurrentPageIndex % _DispPageCount);
                    if (num > 0)
                    {
                        result = ((CurrentPageIndex / _DispPageCount) * _DispPageCount) + 1;
                    }
                    else
                    {
                        result = (((CurrentPageIndex / _DispPageCount)-1) * _DispPageCount) +1;
                    }
                }
                return result;
            }
            
        }

        /// <summary>
        /// 是否Ajax分页 待以后实现
        /// </summary>
        public bool IsAjax { get; set; }
        //public int PageLast
        //{
        //    get
        //    {
        //        int result = TotalPage;
        //        if (this.TotalPage >_DispPageCount && CurrentPageIndex > _DispPageCount)
        //        {
        //            result = CurrentPageIndex + 1;
        //        }
        //        if (result > TotalPage)
        //        {
        //            result = TotalPage;
        //        }
        //        return result;
        //    }

        //}
    }
}